package com.zdf.license.web.controller;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult<T> {
    private int code;
    private String msg;
    private T data;

    public static<T> AjaxResult<T> success(String msg, T data){
        return new AjaxResult<>(200, msg, data);
    }
    public static<T> AjaxResult<T> error(String msg, T data){
        return new AjaxResult<>(500, msg, data);
    }
    public static<T> AjaxResult<T> success(String msg){
        return new AjaxResult<>(200, msg, null);
    }
    public static<T> AjaxResult<T> success(T data){
        return new AjaxResult<>(200, "操作成功", data);
    }
    public static<T> AjaxResult<T> error(String msg){
        return new AjaxResult<>(500, msg, null);
    }
}
